package cn.wyj.fallbackFactory;

import cn.wyj.domain.User;
import cn.wyj.feignclient.UserFeignServer;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserFeignClientFallbackFactory implements FallbackFactory<UserFeignServer> {
    @Override
    public UserFeignServer create(Throwable throwable) {
        // 打印接口错误
        throwable.printStackTrace();

        return new UserFeignServer() {
            @Override
            public User getUserById(Long id) {
                return new User(-1L,"触发熔断","服务不可用");
            }
        };
    }
}
